import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//引入所有icon图标组件
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
//引入暗黑模式
import 'element-plus/theme-chalk/dark/css-vars.css'
//@ts-ignore
import zhCn from 'element-plus/es/locale/lang/zh-cn'
//配置svg
import 'virtual:svg-icons-register'
//引入模板全局样式
import '@/style/index.scss'
//引入svg组件：
import SvgIcon from './components/SvgIcons/index.vue'
//引入商品模块的全局组件三级分类下拉菜单
import Category from '@/components/category/index.vue'
//引入路由信息
import router from './router'
//引入路由鉴权文件
import './permission'
//引入pinia
import pinia from '@/store'
//引入自定义指令
import { isHasButton } from './directive/has'

const app = createApp(App)
//注册全局自定义指令
isHasButton(app)
//注册全局组件
app.component('SvgIcon', SvgIcon)
app.component('Category', Category)

//注册全局图标组件  将ElementPlusIconsVue数组中所有图标组件解构出来然后注册全局组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
//安装pinia
app.use(pinia)
//安装element组件库
app.use(ElementPlus, {
  locale: zhCn,
})
//注册路由
app.use(router)
app.mount('#app')
